<?php


namespace App\Extensions\Exporters;


use App\Patent;
use Encore\Admin\Grid;
use Encore\Admin\Grid\Exporters\ExcelExporter;
use Maatwebsite\Excel\Concerns\WithMapping;

class PatentFeeExporter extends ExcelExporter implements WithMapping
{
    protected $fileName = '专利费用.xlsx';

    protected $columns = [
        'patent_sn' => '专利号',
        'patent.patent_name' => '专利名称',
        'patent.patent_type_id' => '专利类型',
        'patent.apply_date' => '申请日',
        'name' => '缴费名称',
        'amount' => '缴费金额',
        'last_time' => '缴费截止日',
    ];

    public function __construct(Grid $grid = null)
    {
        parent::__construct($grid);
    }

    public function map($row): array
    {
        return [
            ($row->patent->patent_sn??'') . "\t",
            $row->patent->patent_name??'',
             collect(patent_type_select_option())->get($row->patent->patent_type_id),
            ($row->patent->apply_date??'') . "\t",
            $row->name,
            $row->amount,
            $row->last_time,
        ];
    }


}
